package com.group.itms.routes;

import java.io.IOException;
import java.util.HashMap;

import android.app.Application;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;

import com.group.itms.routes.utils.DatabaseUtils;

public class ThisApplication extends Application {

//	private String OSM_MAP_KEY = "XTUMwQ0ZIZ3I0Z0Y1ZTF3NkxYVm93SlZyUnJLWlJVSVFBaFVBczRQdlZ0RDg4ZWM0YkVZWGlYVjErOXRoWVVRPQoKcGFja2FnZU5hbWU9Y29tLmdyb3VwLml0bXMucm91dGVzCndhdGVybWFyaz1PU00KCg";

	private HashMap<String, Object> mGlobalAttributes = new HashMap<String, Object>();
	private static ThisApplication sInstance;

	@Override
	public void onCreate() {
		super.onCreate();
		sInstance = this;
//		populateInitialDB();
	}

	@SuppressWarnings("unused")
	private void populateInitialDB() {
		try {
			DatabaseUtils.populateDBIfNeeded(this, 0);
		} catch (IOException e) {
			// TODO
			Log.e("AppTag", "Can't populate db", e);
		}
	}

	public static ThisApplication getInstance() {
		return sInstance;
	}

	public HashMap<String, Object> getGlobalAttributes() {
		return mGlobalAttributes;
	}

	public Object putAttribute(String key, Object attribute) {
		return mGlobalAttributes.put(key, attribute);
	}

	public Object getAttribute(String key) {
		return mGlobalAttributes.get(key);
	}
	
	public SharedPreferences getPreferences() {
		return PreferenceManager.getDefaultSharedPreferences(this);
	}
}
